<table class="easyui-datagrid"
	   fit="true" border="false" id="contacter_list"
	   singleSelect="true" fitColumns="true" pagination="true"
	   idField="contacter_id" url="y.php?r=contacter/getdata" toolbar="#toolbar_contacter">
	<thead>
	<tr>
		<th field="contacter_name" width="60">姓名</th>
		<th field="position" width="60">职位</th>
		<th field="email" width="80">Email</th>
		<th field="tel" width="60">办公电话</th>
		<th field="phone" width="60">手机</th>
	</tr>
	</thead>
</table>
<div id="toolbar_contacter">
	<?php
	if (Yii::app()->user->checkAccess('contacter_module_view')) {
		?>
		<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-view',plain:true" onclick="contacter_view()" /a>
		<?php
	}
	if (Yii::app()->user->checkAccess('contacter_module_add')) {
		?>
		<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="loadWin('添加联系人','y.php?r=contacter/showedit&contacter_id=0')" /a>
		<?php
	}
	if (Yii::app()->user->checkAccess('contacter_module_edit')) {
		?>
		<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="contacter_showedit()" />
		<?php
	}
	if (Yii::app()->user->checkAccess('contacter_module_remove')) {
		?>
		<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="contacter_remove()" />
		<?php
	}
	?>
</div>
<script>
	function contacter_showedit() {
		//获取选中的列
		var selected = $("#contacter_list").datagrid("getSelected");
		if(selected==null){
			alert('请选择行！');
		}else{
			//进行编辑操作
			loadWin('编辑联系人','y.php?r=contacter/showedit&contacter_id='+selected.contacter_id);
		}
	}
	function contacter_remove() {
		var selected = $("#contacter_list").datagrid("getSelected");
		if(selected==null){
			alert('请选择行！');
		}else{
			$.messager.confirm('确认','您确认想要删除记录吗？',function(r){
				if (r){
					$.post('y.php?r=contacter/remove',{contacter_id:selected.contacter_id},function (res) {
						$("#contacter_list").datagrid("reload");
					});
				}
			});
		}
	}
	function contacter_view() {
		//获取选中的列
		var selected = $("#contacter_list").datagrid("getSelected");
		if(selected==null){
			alert('请选择行！');
		}else{
			//进行编辑操作
			loadWin('查看联系人','y.php?r=contacter/view&contacter_id='+selected.contacter_id);
		}
	}
</script>